<template>
  <div class="app-container">
    <Ht-search-form
      v-show="showSearch"
      :advOptions="[]"
      :dictMap="dictMap"
      :formOptions="formOptions"
      :outputQueryParams="queryParams"
      :queryParams="queryParams"
      :defaultEventKey="defaultEventKey"
      :labelWidth="80"
    ></Ht-search-form>

    <ht-table
      :defaultEventKey="defaultEventKey"
      ref="dataTable"
      :dictMap="dictMap"
      :multi-select="false"
      :opButtonList="opButtonList"
      :queryParams="queryParams"
      :reqConfig="regConfig"
      :showSerialNumber="false"
      :tableBindColumns="tableBindColumns"
    >
      <template v-slot:operate>
        <el-table-column align="left" fixed="right" label="操作" width="120">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    handleAction('detail', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>

    <!-- 添加或修改弹出框 -->
    <el-dialog
      :close-on-click-modal="false"
      :title="title"
      center
      :visible.sync="open"
      v-if="open"
      append-to-body
      width="1024px"
    >
      <el-form ref="detailForm" :model="detailForm" :rules="rules" label-width="140px" :disabled="true">
        <div slot="header" class="label-header-msg">
          <span></span>
        </div>
        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>基本信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="交易流水号" prop="id">
                <el-input v-model="detailForm.id"  />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="报文标识号" prop="pkgId">
                <el-input v-model="detailForm.pkgId"  />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="CPG日期" prop="vdate">
                <el-date-picker
                  v-model="detailForm.vdate"
                  style="width: 100%"
                  type="date"
                  value-format="yyyyMMdd"

                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="工作日期" prop="workdate">
                <el-date-picker
                  v-model="detailForm.workdate"
                  style="width: 100%"
                  type="date"
                  value-format="yyyyMMdd"

                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="来往标识" prop="drct">
                <el-select style="width: 100%" v-model="detailForm.drct" placeholder="来往标识">
                  <el-option
                    v-for="dict in dictMap.DRCTCODE"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>原交易信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原交易流水号" prop="oriId">
                <el-input v-model="detailForm.oriId" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="原报文标识号" prop="oriPkgId">
                <el-input v-model="detailForm.oriPkgId" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原发起参与机构" prop="oriSender">
                <el-input v-model="detailForm.oriSender" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="原发起参与机构名称" prop="oriSenderName">
                <el-input v-model="detailForm.oriSenderName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原报文类型" prop="oriMsgType">
                <el-select style="width: 100%;"
                           v-model="detailForm.oriMsgType===null||detailForm.oriMsgType===undefined?'':detailForm.oriMsgType+'-'+detailForm.oriMsgTypeDesc"
                           placeholder="原报文类型" :disabled="true"
                >

                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

        </el-card>

        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>应答信息</span>
          </div>
            <el-row type="flex">
              <el-col :span="12">
                <el-form-item label="业务回执状态" prop="bizStatus">
                  <el-select style="width: 100%" v-model="detailForm.bizStatus" placeholder="业务回执状态" >
                    <el-option
                      v-for="dict in dictMap.PROCESSSTATUS"
                      :key="dict.value"
                      :label="`${dict.value}-${dict.text}`"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                <el-form-item label="业务拒绝码" prop="bizRejectCode">
                  <el-select style="width: 100%;"
                             v-model="detailForm.bizRejectCode===null||detailForm.bizRejectCode===undefined?'':detailForm.bizRejectCode+'-'+detailForm.bizRejectCodeDesc"
                             placeholder="业务拒绝码" :disabled="true"
                  >
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row type="flex">
              <el-col :span="24">
                <el-form-item label="业务拒绝原因" prop="bizRejectInfo" >
                  <el-input type="textarea" v-model="detailForm.bizRejectInfo"/>
                </el-form-item>
              </el-col>
            </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="业务处理参与机构" prop="bizProOrg">
                <el-input v-model="detailForm.bizProOrg" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="业务处理参与机构名称" prop="bizProOrgName">
                <el-input v-model="detailForm.bizProOrgName" />
              </el-form-item>
            </el-col>
          </el-row>


        </el-card>

        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>业务信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="24">
              <el-form-item label="附言" prop="contents">
                <el-input type="textarea" v-model="detailForm.contents" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="24">
              <el-form-item label="备注" prop="remarks">
                <el-input type="textarea" v-model="detailForm.remarks" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="中心状态" prop="procStatus">
                <el-select style="width: 100%" v-model="detailForm.procStatus" placeholder="中心状态" >
                  <el-option
                    v-for="dict in dictMap.PROCESSSTATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="通讯状态" prop="status">
                <el-select style="width: 100%" v-model="detailForm.status" placeholder="通讯状态" >
                  <el-option
                    v-for="dict in dictMap.PKG_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="发送时间" prop="sndTime">
                <el-date-picker style="width: 100%;" v-model="detailForm.sndTime" value-format="yyyyMMddHHmmss"
                                type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>

      <div slot="footer" align="center" class="dialog-footer">
        <el-button type="primary" @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import {
  apiUrlConfigQuery,
  confirmCollectionPaymentQueryDetail,
} from "@/api/cnaps/beps/389";
import { listPageMixin } from "@/libs/listPageMixin";
import HtAmountInput from "@/views/components/HtAmountInput";
import { amountThousandsFormatter } from "@/utils/table_col_formatter";

export default {
  name: "ConfirmCollectionPaymentQuery",
  mixins: [listPageMixin],
  components: { HtAmountInput },
  data() {
    return {
      defaultEventKey: "defaultEventKey",
      // 查询参数
      queryParams: {
        idSeqno: undefined,
        oriPkgId: undefined,
        startworkdate: undefined,
        endworkdate: undefined,
        workdate1: undefined,
        workdate2: undefined,

      },
      dictMap:{

      },
      // 搜索
      formOptions: [],
      //
      searchFormDictList: [
        "DRCTCODE",
        "Acc_Chg_Flg_Code",
        "PROCESSSTATUS",
        "PKG_STATUS",
        "TXN_STATUS",
        "CHECKFLAG",
        "PKG_NO_388",
        "BIZRT_STATUS",
        "CIS_CODE",
        "BIZ_CTGY_BEPS_E102"
      ],
      // 列信息
      regConfig: apiUrlConfigQuery,

      tableBindColumns: [
        { prop: 'id',  label: '交易流水号',width:180},
        { prop: 'vdate',  label: 'CPG日期', type:'date',width:120},
        { prop: 'workdate',  label: '工作日期', type:'date',width:120},
        { prop: 'oriPkgId',  label: '原报文标识号',width:180},
        { prop: 'oriMsgType', label: '原报文类型', formatter(row, text, index) {
            return (row["oriMsgType"] === null || row["oriMsgType"] === undefined ? "" : row["oriMsgType"]) + "-" + (row["oriMsgTypeDesc"] === null || row["oriMsgTypeDesc"] === undefined ? "" : row["oriMsgTypeDesc"]);
          },width:240
        },
        { prop: 'status',  label: '通讯状态', dictCode : 'PKG_STATUS'},
      ],

      loading: false,
      dictMapAsync: {},
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      detailForm: {
        bizRejectCode:undefined,
        bizRejectInfo:undefined,
        remarks:undefined,
      },


      rules: {

      },
      totalRecord: 0,
      totalPage: 0,
      needCount: 0,

    };
  },
  mounted() {
    const formOptions = [
      // 普通搜索
      {
        type: "input",
        prop: "idSeqno",
        defaultAttr: {
          size: "small",
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },

      {
        type: "input",
        prop: "oriBatchNo",
        defaultAttr: {
          size: "small",
          label: "批序号",
          placeholder: "请输入批序号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "startworkdate",
          endTimeName: "endworkdate",
        },
        defaultAttr: {
          size: "small",
          label: "CPG日期",
          placeholder: ["请输入CPG开始日期", "请输入CPG结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate1",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          size: "small",
          label: "工作日期",
          placeholder: ["请输入工作开始日期", "请输入工作结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },


    ];
    this.formOptions = formOptions;
    this.dictMapAsync = this.getDictMap();
  },
  methods: {
    /***
     * 按钮操作汇总
     */
    /***
     * 按钮操作汇总
     */

    handleAction(type, row = {}) {
      switch (type) {
        case "detail":
          this.handleDetail(row);
          break;
      }
    },

    // 关闭按钮
    cancel() {
      this.open = false;
    },

    //点击重置按钮
    refresh() {
      this.resetForm("detailForm");

    },

    /** 交易明细按钮操作 */
    handleDetail(row) {
      confirmCollectionPaymentQueryDetail(row).then((response) => {
        this.title = " 代收付业务收付款确认查询明细";
        this.detailForm = response.result;
        this.open = true;

      });
    },

  },
};
</script>

<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>

